<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>2D射击游戏（改进版）</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        body {
            font-family: 'Arial', sans-serif;
            overflow: hidden;
            background: #000;
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
        }
        #game-container {
            position: relative;
            width: 800px;
            height: 600px;
        }
        #game-canvas {
            width: 100%;
            height: 100%;
            border: 2px solid #333;
            background: #111;
            box-shadow: 0 0 20px rgba(0, 255, 0, 0.3);
        }
        .menu {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            background: rgba(0, 0, 0, 0.9);
            padding: 2rem;
            border-radius: 10px;
            text-align: center;
            color: #fff;
            z-index: 10;
            border: 2px solid #00ff00;
        }
        .menu h1 {
            font-size: 3rem;
            margin-bottom: 2rem;
            text-shadow: 0 0 20px #0f0;
            color: #00ff00;
        }
        .menu button {
            padding: 1rem 2rem;
            font-size: 1.2rem;
            margin: 0.5rem;
            background: #0f0;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            transition: all 0.3s;
            font-weight: bold;
        }
        .menu button:hover {
            background: #0a0;
            transform: scale(1.1);
        }
        .menu button:active {
            transform: scale(0.95);
        }
        .hidden {
            display: none;
        }
        .game-ui {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            padding: 1rem;
            color: #fff;
            z-index: 5;
            font-size: 1.2rem;
            background: rgba(0, 0, 0, 0.7);
            backdrop-filter: blur(5px);
        }
        .stats {
            display: flex;
            justify-content: space-between;
            font-weight: bold;
        }
        .game-over {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            background: rgba(0, 0, 0, 0.9);
            padding: 2rem;
            border-radius: 10px;
            text-align: center;
            color: #fff;
            z-index: 20;
            border: 2px solid #00ff00;
        }
        .game-over h2 {
            color: #ff0000;
            font-size: 2.5rem;
            margin-bottom: 1rem;
        }
        .api-feedback {
            background: #111;
            border: 1px solid #333;
            border-radius: 5px;
            padding: 1rem;
            margin-top: 1rem;
            max-height: 200px;
            overflow-y: auto;
            font-size: 1rem;
            max-width: 400px;
        }
        .controls {
            position: absolute;
            bottom: 0;
            left: 0;
            width: 100%;
            padding: 1rem;
            color: #fff;
            background: rgba(0, 0, 0, 0.9);
            text-align: center;
            border: 1px solid #333;
        }
        #pause-menu {
            background-color: rgba(0, 0, 0, 0.95);
            border: 2px solid #00ffff;
        }
        #pause-menu h2 {
            color: #00ffff;
            font-size: 2.5rem;
        }
        #level-up {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            background-color: rgba(255, 102, 0, 0.9);
            padding: 30px;
            border-radius: 10px;
            text-align: center;
            font-size: 24px;
            font-weight: bold;
            z-index: 15;
            border: 3px solid #ffaa00;
            text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
        }
        #level {
            color: #00ffff;
        }
        #final-score,
        #enemies-killed,
        #final-level {
            font-size: 1.5rem;
            margin: 0.5rem 0;
            color: #00ff00;
        }
        /* 动画效果 */
        @keyframes pulse {
            0% { opacity: 0.7; }
            50% { opacity: 1; }
            100% { opacity: 0.7; }
        }
        .menu button {
            animation: pulse 2s infinite;
        }
        .menu button:nth-child(odd) {
            animation-delay: 0.5s;
        }
    </style>
</head>
<body>
    <div id="game-container">
        <canvas id="game-canvas"></canvas>
        
        <!-- 主菜单 -->
        <div id="main-menu" class="menu">
            <h1>2D射击游戏</h1>
            <button id="start-game">开始游戏</button>
        </div>
        
        <!-- 游戏UI -->
        <div id="game-ui" class="game-ui hidden">
            <div class="stats">
                <div>生命值: <span id="health">100</span></div>
                <div>得分: <span id="score">0</span></div>
                <div>敌人数: <span id="enemies-count">0</span></div>
                <div>等级: <span id="level">1</span></div>
                <button id="pause-btn">暂停</button>
            </div>
        </div>
        
        <!-- 游戏结束界面 -->
        <div id="game-over" class="game-over hidden">
            <h2>游戏结束！</h2>
            <div id="final-score">最终得分: <span>0</span></div>
            <div id="enemies-killed">消灭敌人: <span>0</span></div>
            <div id="final-level">等级: <span>1</span></div>
            <div class="api-feedback" id="api-feedback">正在获取评价...</div>
            <button id="restart">重新开始</button>
        </div>
        
        <!-- 暂停菜单 -->
        <div id="pause-menu" class="menu hidden">
            <h2>游戏暂停</h2>
            <button id="resume-btn">继续游戏</button>
            <button id="restart-btn">返回主菜单</button>
        </div>
        
        <!-- 升级提示 -->
        <div id="level-up" class="hidden">
            升级！当前等级：1
            场景：太空
        </div>
        
        <!-- 操作说明 -->
        <div id="controls" class="controls hidden">
            控制: WASD移动, 鼠标瞄准射击, 空格射击, Q放大招, P暂停
        </div>
    </div>

    <!-- 游戏主逻辑 -->
    <script src="js/api.js"></script>
    <script src="js/game.js"></script>
</body>
</html>